package com.shou.trigger.http;

import com.shou.types.utils.RSAUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@PropertySource("file:${CONFIG_DIR}/application-car.yml")
@RequestMapping("/api/v1/rsa")
public class RSAController {
    /**
     * 数据加密公钥
     */
    @Value("${rsa.public-key}")
    private String publicKey;

    /**
     * 数据解密私钥
     */
    @Value("${rsa.private-key}")
    private String privateKey;

    /**
     * 获取 RSA 公钥
     * @return 公钥字符串
     */
    @GetMapping("/public-key")
    public String getPublicKey() {
        RSAUtil.setPublicKey(publicKey);
        RSAUtil.setPrivateKey(privateKey);
        return publicKey; // 返回公钥
    }
}